<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('commerce_qualification', function (Blueprint $table) {
            $table->comment('商户资质信息');
            $table->bigIncrements('id')->comment('主键ID');
            $table->bigInteger('merchant_id')->unsigned()->comment('商户ID');
            $table->unsignedTinyInteger('qualification_type')->nullable()->comment('资质类型：1-食品经营许可证，2-卫生许可证，3-消防许可证，4-其他证书');
            $table->string('qualification_name', 32)->nullable()->comment('资质名称');
            $table->string('qualification_id', 64)->nullable()->comment('资质证书号');
            $table->string('issuing_authority', 64)->nullable()->comment('发证机关');
            $table->date('issue_date')->nullable()->comment('发证日期');
            $table->date('expiry_date')->nullable()->comment('有效期至');
            $table->string('qualification_file', 255)->nullable()->comment('资质文件路径');
            $table->string('remark', 255)->nullable()->comment('备注');
            $table->index('merchant_id', 'idx_merchant_id');
            $table->index('qualification_type', 'idx_qualification_type');
            $table->index('expiry_date', 'idx_expiry_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('commerce_qualification');
    }
};